package cn.xuziao.databasecourse.dao;

import cn.xuziao.databasecourse.pojo.ComplexInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author xuziao
 * @date 2021/11/10 9:22
 */
@Repository
@Mapper
public interface ComplexInfoMap {
    @Insert("insert into cnki(info_type, pdf_path, image_path, name, author)" +
            " values (#{info_type}, #{pdf_path}, #{image_path}, #{name}, #{author})")
    int InsertComplexInfo(ComplexInfo complexInfo);

    @Select("Select * from cnki where name like #{info} or author like #{info}")
    List<ComplexInfo> selectComplexInfo(String info);

    @Select("Select * from cnki where ${infoType} like ${value}")
    List<ComplexInfo> selectComplexInfoByType(String infoType, String value);

    @Select("Select * from cnki where id = #{id}")
    ComplexInfo selectComplexInfoById(int id);

}
